import React, { Component } from 'react'
import A from './A'
// !#1 创建 Context 对象
import { Context } from './context'

export default class App extends Component {
  state = {
    count: 8,
  }
  changeCount = (count) => {
    this.setState({ count: this.state.count + count })
  }
  render() {
    // !#2 使用 Context.Provider 配合 value 属性提供数据
    return (
      <Context.Provider
        value={{
          count: this.state.count,
          changeCount: this.changeCount,
        }}
      >
        <div>
          App
          <hr />
          <A />
        </div>
      </Context.Provider>
    )
  }
}
